package com.uusee.util;

import java.lang.reflect.Array;

public class HashCodeBuilder {
	public HashCodeBuilder() {
	}
	final int prime = 31;
	private int result = 1;
	
	public HashCodeBuilder append(Object field) {
		if(field == null) {
			result = prime * result + 0;
		} else if (field.getClass().isArray()) {
			for (int i = Array.getLength(field) - 1; i >= 0; i--) {
				append(Array.get(field, i));
			}
		} else {
			result = prime * result + field.hashCode();
		}
		return this;
	}

	@Override  
	public int hashCode() {  
		return result;  
	}
	@Override  
	public String toString() {  
		return String.valueOf(result);  
	} 
}
